//
//  MarriageDetailViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/1.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "MarriageDetailViewController.h"

@interface MarriageDetailViewController ()
@property (nonatomic,strong) NSMutableArray *otherHolidaysArr;
@end

@implementation MarriageDetailViewController



#pragma mark -婚假申请 暂时不用
- (void)viewDidLoad {
    [super viewDidLoad];
    [self getDropListRequestWithdataSwith:self.keywordId isDetailList:NO];
    // Do any additional setup after loading the view.
}

#pragma mark -初始化数据
- (void)dataInit{
    self.otherHolidaysArr=[NSMutableArray new];
    self.mustSelectArr=[NSMutableArray new];
    self.addWorkPersonArr=[NSMutableArray new];
    _titleArr=@[@"开始时间 :",@"结束时间 :",@"请假天数 :"];
    _messageArr=[NSMutableArray arrayWithArray:@[self.beginStr?self.beginStr:@"点击选择",self.endStr?self.endStr:@"点击选择",@"0  天"]];
    if (self.beginStr&&self.endStr) {
        [self getVacateDaysOnlyRequest];
    }
}

#pragma mark -页面请假信息请求成功
- (void)getVacateInfoRequestSuccess:(id)responseObject{
    //解析数据
    self.infoModel=[[VacateInfoModel alloc]initWithResponse:responseObject];
    self.beginStr=self.infoModel.vacateBeginTime;
    self.endStr=self.infoModel.vacateEndTime;
    self.taskId=self.infoModel.TaskID;
    NSString *dayStr=[NSString stringWithFormat:@"%@  天",self.infoModel.vacateDays];
    self.reasonTextView.text=self.infoModel.vacateReason;
    self.reasonTextView.textColor=[UIColor blackColor];
    //替换数据
    _messageArr=[NSMutableArray arrayWithArray:@[self.beginStr?self.beginStr:@"点击选择",self.endStr?self.endStr:@"点击选择",dayStr]];
    
    //保存委托人
    if (self.infoModel.workEntrustList.count>0) {
        for (int i=0; i<self.infoModel.workEntrustList.count; i++) {
            VacateInfoModel *model=self.infoModel.workEntrustList[i];
            DepartPersonListModel *personModel=[DepartPersonListModel new];
            personModel.personId=model.ids;
            personModel.personName=model.entrustMan;
            personModel.beginStr=model.entrustBeginTime;
            personModel.endStr=model.entrustEndTime;
            personModel.msgContent=model.taskDescribe;
            [self.addWorkPersonArr addObject:personModel];
        }
    }
    [self getTimeControlRequestWithBeginTime:self.beginStr endTime:nil type:@"Begin"];
    [self getTimeControlRequestWithBeginTime:self.beginStr endTime:self.endStr type:@"End"];
    [self getVacateDaysOnlyRequest];
    [_tableView reloadData];
}
#pragma mark -textViewDelegate

- (void)textViewDidBeginEditing:(UITextView *)textView{
    //滚动输入框 避免被键盘遮挡
    [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor clearColor]];
    NSIndexPath* path = [NSIndexPath indexPathForRow:3 inSection:2];
    [self performSelector:@selector(scrollToCell:) withObject:path afterDelay:0];
}


#pragma mark -textFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(CustomField *)textField{
    textField.color=COLOR_SKYBLUE;
    //[self addTapGestureRecognizer];
    //将输入的部分滚动到顶部  以免被键盘遮挡
    NSIndexPath* path = [NSIndexPath indexPathForRow:textField.tag-700 inSection:1];
    [self performSelector:@selector(scrollToCell:) withObject:path afterDelay:0];
    return YES;
}

- (BOOL)textFieldShouldEndEditing:(CustomField *)textField{
    textField.color=[UIColor lightGrayColor];
    //[self removeTapGestureRecognizer];
    //当结束输入时 如果有内容 先将用户输入的信息保存
    //    if (textField.ta) {
    //        <#statements#>
    //    }
    [_otherHolidaysArr replaceObjectAtIndex:textField.tag-700-self.dropListModel.dataArr.count-2 withObject:textField.text];
    [self updateHolidayInfo];
    return YES;
}

- (void)updateHolidayInfo{
    //遍历所有的可输入框 计算请假总和
    CGFloat holidaysNum=0;
    for (NSString *holidays in _otherHolidaysArr) {
        holidaysNum+=holidays.floatValue;
    }
    self.holidayCountLabel.text=[NSString stringWithFormat:@"%.2lf  天",[self.systemHolidaycount floatValue]+holidaysNum];
    [_messageArr replaceObjectAtIndex:2 withObject:self.holidayCountLabel.text];
    
    if (self.beginStr) {
        NSString *days=[NSString stringWithFormat:@"%.2f",[self.systemHolidaycount integerValue]+holidaysNum];
        self.endTimeLabel.text=[self getEndDateStrWithDays:[days floatValue] beginStr:self.beginStr];
        [_messageArr replaceObjectAtIndex:1 withObject:self.endTimeLabel.text];
    }
}
#pragma mark -限制输入的长度
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (string.length == 0) return YES;
    
    NSInteger existedLength = textField.text.length;
    NSInteger selectedLength = range.length;
    NSInteger replaceLength = string.length;
    //第一个不允许输入小数点
    if (textField.text.length==0&&[string isEqualToString:@"."]) {
        return NO;
    }
    //不允许出啊先两个小数点
    if ([textField.text containsString:@"."]&&[string isEqualToString:@"."]) {
        return NO;
    }
    NSInteger count=2;
    //有小数点则限制为4为  整数为2位
    if ([textField.text containsString:@"."]||[string isEqualToString:@"."]) {
        count=4;
    }
    if (existedLength - selectedLength + replaceLength > count) {
        return NO;
    }
    
    return YES;
}



#pragma mark -选择请假原因
- (void)selectButtonClick:(NSIndexPath *)indexPath{
    for (int i=0; i<self.dropListModel.dataArr.count; i++) {
        DutyDropModel *model=self.dropListModel.dataArr[i];
        //因为第一个row为title  所有在这需要减一
        if (i==indexPath.row-1) {
            model.isSelect=YES;
            self.lawDayLabel.text=[model.keyValue stringByAppendingString:@"天"];
            [self updateHolidayInfo];
            self.systemHolidaycount=model.keyValue;
            self.BaseTypeId=[model.keywordId copy];
            //如果选择了开始时间  需要重新计算结束时间
            [self updateHolidayInfo];
            //            if (self.beginStr) {
            //                NSString *days=[NSString stringWithFormat:@"%ld",[self.systemHolidaycount integerValue]+[self.textField.text integerValue]];
            //                self.endTimeLabel.text=[self getEndDateStrWithDays:[days floatValue] beginStr:self.beginStr];
            //            }
        }else{
            model.isSelect=NO;
        }
        //刷新所有的row  根绝model保存的数据设置按钮的点击状态
        //设置row为 i+1是因为 i是从0开始而第一个row为title  所以row从第二个开始刷新
        [_tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:i+1 inSection:1]] withRowAnimation:UITableViewRowAnimationNone];
    }
    //    [_tableView reloadSections:[[NSIndexSet alloc]initWithIndex:1] withRowAnimation:UITableViewRowAnimationFade];
}

#pragma mark -法律法规按钮点击
- (void)lawButtonClick{
    LawDetailViewController *law=[LawDetailViewController new];
    law.navaTitle=self.navaTitle;
    law.businessCode=self.businessCode;
    [self.navigationController pushViewController:law animated:YES];
}

#pragma mark - TableViewDelagate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section==2) {
        return 4;
    }else if (section==3){
        //根据返回数据多少设置row
        return self.addWorkPersonArr.count+1;
    }else if (section==1){
        //因为section里面包含了两个数据源和两个title  所以要计算他们的总和
        return self.dropListModel.dataArr.count+self.dropDetailListModel.dataArr.count+2;
    }
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //申请人
    if (indexPath.section==0) {
        NSString *cellID=@"DutyBasicTableViewCell";
        DutyBasicTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell=[[DutyBasicTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
        }
        cell.myTitleLabel.text=@"申  请  人 :";
        self.userTitleLabel=cell.myTitleLabel;
        cell.messageLabel.text=[NSString stringWithFormat:@"%@ ( %@ )",[LZXHelper getUserName],[LZXHelper getUserDepartName]];
        return cell;
        
    }else if(indexPath.section==2){
        //请假理由
        if (indexPath.row==3) {
            NSString *cellID=@"ReasonTextTableViewCell";
            ReasonTextTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[ReasonTextTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID title:@" 请填/选请假事由 : " noticeStr:nil];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
            }
            self.reasonTextView=cell.reasonTextView;
            self.reasonTextView.delegate=self;
            self.reasonTitleLabel=cell.myTitleLabel;
            return cell;
        }else{
            NSString *cellID=@"DutyBasicTableViewCell1";
            DutyBasicTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[DutyBasicTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                [cell.signButton addTarget:self action:@selector(signButtonClick:) forControlEvents:UIControlEventTouchUpInside];
            }
            
            //保存疑问按钮
            if (indexPath.row==0) {
                self.beginSignButton=cell.signButton;
                self.beginTitleLabel=cell.myTitleLabel;
            }else if (indexPath.row==1){
                self.endSignButton=cell.signButton;
                self.endTitleLabel=cell.myTitleLabel;
                self.endTimeLabel=cell.messageLabel;
            }
            //填充内容
            if (indexPath.row<3) {
                cell.myTitleLabel.text=_titleArr[indexPath.row];
                cell.messageLabel.text=_messageArr[indexPath.row];
            }
            if (indexPath.row==0||indexPath.row==1) {
                cell.arrowImageView.hidden=NO;
                if ([cell.messageLabel.text isEqualToString:@"点击选择"]) {
                    cell.messageLabel.textColor=[UIColor lightGrayColor];
                }else{
                    cell.messageLabel.textColor=[UIColor blackColor];
                }
                
            }else{
                cell.arrowImageView.hidden=YES;
            }
            if (indexPath.row==2) {
                self.holidayCountLabel=cell.messageLabel;
                self.holidaysTitleLabel=cell.myTitleLabel;
                cell.messageLabel.textColor=[UIColor blackColor];
            }
            return cell;
            
        }
    }else if (indexPath.section==1){
        //请假类型的title设置
        if (indexPath.row==0||indexPath.row==self.dropListModel.dataArr.count+1) {
            NSString *cellID=@"DutyLawTitleTableViewCell";
            DutyLawTitleTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[DutyLawTitleTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID isNeedButton:YES];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                [cell.signButton addTarget:self action:@selector(lawButtonClick) forControlEvents:UIControlEventTouchUpInside];
            }
            if (indexPath.row==0) {
                cell.myTitleLabel.text=@"法定期限 :";
                //                cell.messageLabel.text=@"20天";
                cell.signButton.hidden=NO;
                self.lawDayLabel=cell.messageLabel;
                if (self.dropListModel) {
                    if (self.dropListModel.dataArr.count>0) {
                        DutyDropModel *model=self.dropListModel.dataArr[0];
                        cell.messageLabel.text=[model.keyValue stringByAppendingString:@"天"];
                    }
                }
                
            }else{
                cell.myTitleLabel.text=@"其他情形 :";
                cell.messageLabel.text=@"";
                cell.signButton.hidden=YES;
            }
            return cell;
            //设置可选的请假类型
        }else if (indexPath.row<=self.dropListModel.dataArr.count){
            NSString *cellID=@"DropListTableViewCell";
            DropListTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[DropListTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                //[cell.signButton addTarget:self action:@selector(selectButtonClick:) forControlEvents:UIControlEventTouchUpInside];
            }
            //cell.signButton.tag=1000+indexPath.row-1;
            DutyDropModel *model=self.dropListModel.dataArr[indexPath.row-1];
            cell.signButton.selected=model.isSelect;
            cell.myTitleLabel.text=model.keyword;
            cell.myTitleLabel.textColor=[UIColor lightGrayColor];
            return cell;
            //路程假的设置
        }else{
            NSString *cellID=@"DropDetailListTableViewCell";
            DropDetailListTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[DropDetailListTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
            }
            DutyDropModel *model=self.dropDetailListModel.dataArr[indexPath.row-2-self.dropListModel.dataArr.count];;
            cell.myTitleLabel.text=model.keyword;
            cell.myTitleLabel.textColor=[UIColor lightGrayColor];
            //设置代理
            cell.textField.tag=700+indexPath.row;
            cell.textField.delegate=self;
            self.textField=cell.textField;
            return cell;
        }
    }else{
        //添加工作委托的按钮
        if (indexPath.row==0) {
            NSString *cellID=@"CenterLabelTableViewCell";
            CenterLabelTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[CenterLabelTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
            }
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
            cell.myTitle.text=@"点击此处添加工作委托";
            return cell;
            //工作委托人的列表
        }else{
            NSString *cellID=@"AddPersonListTableViewCell";
            AddPersonListTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[AddPersonListTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
            }
            //因为第一个row为title  所以在此需要减一
            DepartPersonListModel *model=self.addWorkPersonArr[indexPath.row-1];
            cell.myTitleLabel.text=model.personName;
            cell.messageLabel.text=[NSString stringWithFormat:@"%@ 至 %@",model.beginStr,model.endStr];
            return cell;
        }
    }
    //    [cell.headImageView setImage:[UIImage imageNamed:_imageArr[indexPath.section][indexPath.row]]];
    //    cell.myTitle.text=_titleArr[indexPath.section][indexPath.row];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.reasonTextView resignFirstResponder];
    if (indexPath.section==2) {
        if (indexPath.row==0){
            NSString *dateStr=nil;
            if (self.beginStr) {
                dateStr=self.beginStr;
            }else if (self.endStr){
                dateStr=self.endStr;
            }
            //创建日期选择view
            DatePickerView *datePickerView=[[DatePickerView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT)nowDateStr:dateStr];
            __weak NSMutableArray *myMessageArr=_messageArr;
            __weak UITableView *myTableView=_tableView;
            __weak DutyParentsViewController *mySelf=self;
            datePickerView.sureBlock=^(NSString *timeStr){
                if (indexPath.row==0) {
                    //如果是选择开始时间
                    //先判断有没有结束时间,如果有要进行比对
                    //                    if (mySelf.endStr) {
                    //                        if (![mySelf compareOneTime:mySelf.beginStr withAnotherTime:mySelf.endStr]) {
                    //                            [LZXHelper postMessageWithText:@"请假结束时间应该在请假开始时间之后!" View:mySelf.view];
                    //                        }
                    //                    }
                    if (mySelf.dutyType==ApplyHoliday) {
                        //如果是请假
                        if ([mySelf compareTime:timeStr]) {
                            //比现在的时间早
                            [LZXHelper postAlertViewControllerWithTitle:@"您选择的请假开始时间早于今天,要补假吗?" message:nil cancelButtonTitle:@"选错时间了" otherButtonTitle:@"去补假" cancelEvent:^{
                                
                            } otherEvent:^{
                                mySelf.dutyType=1;
                                
                                [mySelf setNavigationTitle:[mySelf.navaTitle stringByAppendingString:@"补假申请"]];
                                
                            } viewController:mySelf];
                        }else{
                            //比现在的时间晚
                            mySelf.beginStr=[timeStr copy];
                            //获取法律所规定的时间
                            //                            NSString *days=[self.lawDayLabel.text substringToIndex:self.lawDayLabel.text.length-1];
                            //                            NSString *days=[NSString stringWithFormat:@"%ld",[self.systemHolidaycount integerValue]+[self.textField.text integerValue]];
                            //                            mySelf.endTimeLabel.text=[mySelf getEndDateStrWithDays:[days floatValue] beginStr:mySelf.beginStr];
                            [self updateHolidayInfo];
                            mySelf.endTimeLabel.textColor=[UIColor blackColor];
                            mySelf.endStr=mySelf.endTimeLabel.text;
                            [mySelf setLabelBorderColorWithLabel:mySelf.beginTitleLabel color:[UIColor clearColor]];
                            //替换数据源数组 并刷新
                            [myMessageArr replaceObjectAtIndex:indexPath.row withObject:timeStr];
                            [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
                            [mySelf getTimeControlRequestWithBeginTime:[timeStr copy]endTime:nil type:@"Begin"];
                            [mySelf getVacateDaysOnlyRequest];
                            [mySelf getTimeControlRequestWithBeginTime:mySelf.beginStr endTime:mySelf.endStr type:@"End"];
                        }
                        
                    }else{
                        //如果是补假
                        if ([mySelf compareTime:timeStr]){
                            //比现在的时间早
                            mySelf.beginStr=[timeStr copy];
                            //                            NSString *days=[NSString stringWithFormat:@"%ld",[self.systemHolidaycount integerValue]+[self.textField.text integerValue]];
                            //                            mySelf.endTimeLabel.text=[mySelf getEndDateStrWithDays:[days floatValue] beginStr:mySelf.beginStr];
                            [self updateHolidayInfo];
                            mySelf.endStr=mySelf.endTimeLabel.text;
                            mySelf.endTimeLabel.textColor=[UIColor blackColor];
                            [mySelf setLabelBorderColorWithLabel:mySelf.beginTitleLabel color:[UIColor clearColor]];
                            //替换数据源数组 并刷新
                            [myMessageArr replaceObjectAtIndex:indexPath.row withObject:timeStr];
                            [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
                            [mySelf getTimeControlRequestWithBeginTime:[timeStr copy]endTime:nil type:@"Begin"];
                            [mySelf getVacateDaysOnlyRequest];
                            [mySelf getTimeControlRequestWithBeginTime:mySelf.beginStr endTime:mySelf.endStr type:@"End"];
                        }else{
                            //比现在的时间晚
                            [LZXHelper postAlertViewControllerWithTitle:@"您选择的请假开始时间晚于今天,要请假吗?" message:nil cancelButtonTitle:@"选错时间了" otherButtonTitle:@"去请假" cancelEvent:^{
                                
                            } otherEvent:^{
                                mySelf.dutyType=0;
                                [mySelf setNavigationTitle:[mySelf.navaTitle stringByAppendingString:@"申请"]];
                            } viewController:mySelf];
                        }
                    }
                    
                }
                //                else{
                //                    //点击结束时间
                //                    mySelf.endStr=[timeStr copy];
                //                    [mySelf setLabelBorderColorWithLabel:mySelf.endTitleLabel color:[UIColor clearColor]];
                //                    [myMessageArr replaceObjectAtIndex:indexPath.row withObject:timeStr];
                //                    [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                //                    [mySelf getVacateDaysOnlyRequest];
                //                    [mySelf getTimeControlRequestWithBeginTime:mySelf.beginStr endTime:[timeStr copy] type:@"End"];
                //                }
            };
            [[[UIApplication sharedApplication].delegate window] addSubview:datePickerView];
        }
    }else if (indexPath.section==3&&indexPath.row==0){
        if (!self.beginStr) {
            [LZXHelper postMessageWithText:@"请假开始时间不能为空!" View:self.view];
            return;
        }
        if (!self.endStr) {
            [LZXHelper postMessageWithText:@"请假结束时间不能为空!" View:self.view];
            return;
        }
        //跳转到增加委托人页面
        AddWorkPersonViewController *person=[AddWorkPersonViewController new];
        person.dutyType=self.dutyType;
        person.beginStr=self.beginStr;
        person.endStr=self.endStr;
        __weak UITableView *myTableView=_tableView;
        //增加委托人回调函数 并刷新列表
        person.myBlock=^(DepartPersonListModel *model){
            [self.addWorkPersonArr addObject:model];
            [myTableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section]  withRowAnimation:UITableViewRowAnimationNone];
        };
        [self.navigationController pushViewController:person animated:YES];
    }else if(indexPath.section==1){
        //如果是点击选择请假类型需要切换按钮状态
        if (indexPath.row<=self.dropListModel.dataArr.count&&indexPath.row>0){
            [self selectButtonClick:indexPath];
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    //如果是添加工作委托
    if (indexPath.section==3) {
        
        if (indexPath.row==0) {
            return 50;
        }else{
            return 64;
        }
        //请假内容
    }else if (indexPath.section==2){
        if (indexPath.row==3) {
            return 100;
        }else{
            return 50;
        }
    }
    return 50;
}

//开启编辑模式
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section==3&&indexPath.row!=0) {
        return YES;
    }
    return NO;
}
-(NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"删除";
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 从数据源中删除
    [self.addWorkPersonArr removeObjectAtIndex:indexPath.row-1];
    // 从列表中删除
    [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}


#pragma mark -可选择请假类型请求成功
- (void)dropListModelRequestSuccess{
    //刷新数据
    [_tableView reloadSections:[[NSIndexSet alloc]initWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
    if (self.dropListModel) {
        if (self.dropListModel.dataArr.count>0) {
            //默认选择第一个请求请假类型的详情
            DutyDropModel *model=self.dropListModel.dataArr[0];
            [self getDropListRequestWithdataSwith:model.keywordId isDetailList:YES];
            //填充数据
            [self updateHolidayInfo];
            self.systemHolidaycount=model.keyValue;
            self.BaseTypeId=[model.keywordId copy];
        }
    }
}

#pragma mark -可选择请假日期请求成功
- (void)dropDetailListModelRequestSuccess{
    //刷新数据
    //其他请假时间初始化
    for (int i=0; i<self.dropDetailListModel.dataArr.count; i++) {
        [_otherHolidaysArr addObject:@""];
    }
    [self updateHolidayInfo];
    [_tableView reloadSections:[[NSIndexSet alloc]initWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
}
#pragma mark -提交请求
- (void)submitApplyRequestWithState:(NSString *)state{
    //    if (self.textField.text.length>0) {
    //        self.holidayCount=[NSString stringWithFormat:@"%.2f",[self.systemHolidaycount floatValue]+[self.textField.text floatValue]];
    //    }
    //计算总和
    CGFloat holidaysNum=0;
    for (NSString *holidays in _otherHolidaysArr) {
        holidaysNum+=holidays.floatValue;
    }
    self.holidayCount=[NSString stringWithFormat:@"%.2f",[self.systemHolidaycount floatValue]+holidaysNum];
    [super submitApplyRequestWithState:state];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
